home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 1996 #6 / Amiga Plus CD - 1996 - No. 06.iso / pd / programmierung / proasm / examples / cxdemo / cxdemo.s < prev   
Text File  |  1996-04-25  |  6KB  |  241 lines

  1. ;-------------------------------------------------------------------------------
  2. *                                                                              *
  3. * CXDemo    - Commodity Demo Program                                       *
  4. *                                                                              *
  5. * Written 1993 by Daniel Weber                                                 *
  6. *                                                                              *
  7. * This small demo program shows you how to use the commodity.r routines.       *
  8. * Don't look at this code (it's a mess), but use it as a reference.            *
  9. * Use the C= Exchange program to test it, and try to start it again while      *
  10. * one demo is already running...                                               *
  11. * Have fun! Daniel.                                                            *
  12. *                                                                              *
  13. *                                                                              *
  14. *       Filename        cxdemo.s                                               *
  15. *       Author          Daniel Weber                                           *
  16. *       Version         0.20                                                   *
  17. *       Start           06.04.93                                               *
  18. *                                                                              *
  19. *       Last Revision   25.12.93                                               *
  20. *                                                                              *
  21. ;-------------------------------------------------------------------------------
  22.  
  23.     output    'ram:cxdemo'
  24.  
  25.     opt    o+,q+,ow-,qw-,sw-,f+
  26.     verbose
  27.     base    progbase
  28.  
  29. ;-------------------------------------------------------------------------------
  30.  
  31.     incdir    'include:'
  32.     incdir    'routines:'
  33.  
  34.     incequ    'LVO.s'
  35.     include    'structs.r'
  36.     include    'exec/ports.i'
  37.     include    'dos/dos.i'
  38.     include    'support.mac'
  39.     include    'basicmac.r'
  40.  
  41. ;-------------------------------------------------------------------------------
  42.  
  43. version        equr    "0.10"
  44. gea_progname    equr    "cxdemo"
  45.  
  46. ;-- startup control  --
  47. ;cws_V36PLUSONLY    set    1        ;only OS2.x or higher
  48. ;cws_DETACH    set    1            ;detach from CLI
  49. cws_CLIONLY    set    1            ;for CLI usage only
  50. ;cws_PRI    equ    0            ;set process priority to 0
  51. ;cws_FPU    set    1
  52.  
  53. ;-- user definitions --
  54. AbsExecBase    equ    4
  55. DOS.LIB        set    36
  56. COMMODITIES.LIB    set    36
  57.  
  58.  
  59. cx_id        equ    93
  60.  
  61. ;-------------------------------------------------------------------------------
  62. progbase:
  63.     jmp    AutoDetach(pc)
  64.     dc.b    0,"$VER: ",gea_progname," ",version," (",__date2,")",0
  65.     even
  66. ;----------------------------
  67. start:
  68.  
  69. clistartup:
  70. wbstartup:
  71.     lea    progbase(pc),a5
  72.     bsr    OpenLibrary
  73.     beq.s    .out
  74.  
  75. *
  76. * install a broker
  77. *
  78.     lea    myPort(pc),a0
  79.     lea    myBroker(pc),a1
  80.     CALL_    InitBroker        ;install broker
  81.     move.l    d0,broker(a5)
  82.     beq.s    .out
  83.     move.l    d1,brokerport(a5)
  84.  
  85. *
  86. * HotKey
  87. *
  88.     lea    HotKeyString(pc),a0
  89.     move.l    d0,a1            ;broker
  90.     move.l    d1,a2            ;message port
  91.     moveq    #cx_id,d0        ;ID
  92.     CALL_    InstallHotKey        ;add a hot key triade
  93.     tst.l    d0
  94.     beq.s    .out
  95.     move.l    broker(pc),a0
  96.     CALL_    EnableCX
  97. *
  98. * do the main
  99. *
  100.     bsr    main            ;wait...
  101.     moveq    #0,d0
  102.     move.l    broker(pc),a0
  103.     move.l    brokerport(pc),a1
  104.     CALL_    RemoveBroker        ;remove all
  105. .out:    bsr    CloseLibrary        ;quit
  106.     bra    ReplyWBMsg
  107.  
  108.  
  109.  
  110. ;-------------------------------------------------------------------------------
  111. *
  112. * main - just do it...
  113. *
  114. ;-------------------------------------------------------------------------------
  115. main:    print_    <"CXDemo: HotKey=<lcommand help>>; press CTRL-C to quit...",$a>
  116.  
  117. loop:    moveq    #0,d0
  118.     moveq    #0,d1
  119.     move.l    brokerport(pc),a0
  120.     move.b    MP_SIGBIT(a0),d1
  121.     bset    d1,d0
  122.     or.l    #SIGBREAKF_CTRL_C,d0    ;ctrl-c
  123.     move.l    4.w,a6
  124.     jsr    _LVOWait(a6)
  125.     move.l    d0,d1
  126.     and.l    #SIGBREAKF_CTRL_C,d1
  127.     bne    outmain
  128.  
  129.     move.l    brokerport(pc),a0
  130.     jsr    _LVOGetMsg(a6)
  131.     move.l    d0,a0
  132.     move.l    a0,d0
  133.     beq    loop            ;nothing
  134.  
  135.     move.l    a0,a4            ;store
  136.     move.l    CxBase(pc),a6
  137.     jsr    _LVOCxMsgID(a6)
  138.     move.l    d0,d7
  139.  
  140.     move.l    a4,a0
  141.     jsr    _LVOCxMsgType(a6)
  142.     move.l    d0,d6
  143.  
  144.     move.l    4.w,a6
  145.     move.l    a4,a1
  146.     jsr    _LVOReplyMsg(a6)
  147.  
  148.  
  149.     cmp.l    #CXM_IEVENT,d6
  150.     beq    cxmevent
  151.     cmp.l    #CXM_COMMAND,d6
  152.     beq    cxmcommand
  153.     print_    <"unknown message type",$a>
  154.     bra    loop
  155.  
  156.  
  157. cxmevent:
  158.     print_    "A CXM_EVENT, "
  159.     cmp.l    #cx_id,d7
  160.     bne    unknownID
  161.     print_    <"you hit the HotKey man... wooow",$a>
  162.     bra    loop
  163.  
  164. cxmcommand:
  165.     print_    "A command: "
  166.     cmp.l    #CXCMD_DISABLE,d7
  167.     bne.s    1$
  168.     print_    <"CXCMD_DISABLE",$a>
  169.     bra    loop
  170.  
  171. 1$:    cmp.l    #CXCMD_ENABLE,d7
  172.     bne.s    2$
  173.     print_    <"CXCMD_ENABLE",$a>
  174.     bra    loop
  175.  
  176. 2$:    cmp.l    #CXCMD_KILL,d7
  177.     bne.s    3$
  178.     print_    <"CXCMD_KILL",$a>
  179.     bra    loop
  180.  
  181. 3$:    cmp.l    #CXCMD_UNIQUE,d7
  182.     bne.s    4$
  183.     print_    <"CXCMD_UNIQUE",$a>
  184.     bra    loop
  185.  
  186. 4$:    cmp.l    #CXCMD_APPEAR,d7
  187.     bne.s    5$
  188.     print_    <"CXCMD_APPEAR",$a>
  189.     bra    loop
  190.  
  191. 5$:    cmp.l    #CXCMD_DISAPPEAR,d7
  192.     bne.s    6$
  193.     print_    <"CXCMD_DISAPPEAR",$a>
  194.     bra    loop
  195.  
  196. 6$:    cmp.l    #CXCMD_LIST_CHG,d7
  197.     bne.s    unknownID
  198.     print_    <"CXCMD_LIST_CHG",$a>
  199.     bra    loop
  200.  
  201.  
  202.  
  203. unknownID:
  204.     print_    <"unknown.",$a>
  205.     bra    loop
  206.  
  207. outmain:
  208.     rts
  209.  
  210.  
  211.  
  212. ;-------------------------------------------------------------------------------
  213. *
  214. * external routines
  215. *
  216. ;-------------------------------------------------------------------------------
  217.     include    startup4.r
  218.     include    commodity.r
  219.     include    easylibrary.r
  220.  
  221. ;-------------------------------------------------------------------------------
  222. *
  223. * Data stuff....
  224. *
  225. ;-------------------------------------------------------------------------------
  226. HotKeyString:    dc.b    "lcommand help",0
  227.         even
  228.  
  229.  
  230. myPort:   PortStruct_    "CXDemo Port"
  231. myBroker: BrokerStruct_    "CXDemo","cxdemo - commodity.r test",,,,"Juhu description!"
  232.  
  233.  
  234. broker:        dc.l    0
  235. brokerport:    dc.l    0
  236.  
  237.  
  238.  
  239.     end
  240.  
  241.